<?php

namespace PointPresse\BlogBundle\Form;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;

class PostType extends AbstractType
{
    public function __construct($options = null) {
        $this->options = $options;
    }
        /**
     * @param FormBuilderInterface $builder
     * @param array $options
     */
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('subject','text')
            ->add('content','textarea',array('attr'=> array('class'=>'ckeditor')))
            ->add('idCat', 'choice', array(
                'choices' =>$this->options['categories'],
                'required' => true,
                'label'=> 'Catégorie',
                'multiple' => false
                  ));
        ;
    }
    
    /**
     * @param OptionsResolverInterface $resolver
     */
    public function setDefaultOptions(OptionsResolverInterface $resolver)
    {
        $resolver->setDefaults(array(
            'data_class' => 'PointPresse\BlogBundle\Entity\Post'
        ));
    }

    /**
     * @return string
     */
    public function getName()
    {
        return 'pointpresse_blogbundle_post';
    }
}
